﻿#region Using directives
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
#endregion

namespace gpsMe.Classes
{
    /// <summary>
    /// Logger that allows the GPS Provider to log the events
    /// </summary>
    public class gpsMeGpsLogger
    {
        #region Instance
        /// <summary>
        /// Current gpsMeGpsLogger instance
        /// </summary>
        private static gpsMeGpsLogger instance;

        /// <summary>
        /// Indicates if instance is null
        /// </summary>
        private static bool isInstanciated = false;

        /// <summary>
        /// Current gpsMeGpsLogger instance
        /// </summary>
        public static gpsMeGpsLogger Instance
        {
            get
            {
                if (!isInstanciated)
                {
                    new gpsMeGpsLogger();
                    isInstanciated = true;
                }
                return instance;
            }
            private set
            {
                instance = value;
            }
        }
        #endregion

        #region Attributes
        /// <summary>
        /// Text of the log
        /// </summary>
        private string text;
        #endregion

        #region Accessors
        /// <summary>
        /// Text of the log
        /// </summary>
        public string Text
        {
            get
            {
                return this.text;
            }
            set
            {
                this.text = value;
                if (TextChanged != null)
                    TextChanged(this, new EventArgs());
            }
        }
        #endregion

        #region Events
        /// <summary>
        /// Invoked when the log text has ben changed
        /// </summary>
        public event EventHandler TextChanged;
        #endregion

        #region Constructor
        public gpsMeGpsLogger()
        {
            Instance = this;
            this.Text = "";
        }
        #endregion
    }
}
